package cn.jinjimi.app.main.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import cn.jinjimi.app.R;
import cn.jinjimi.app.entity.Company;
import cn.jinjimi.app.main.adapter.extend.MyBaseAdapter;

/**
 * 所有客户列表的adapter
 * <p/>
 * Created by jinsen on 15/10/22.
 */
public class CompanyListAdapter extends MyBaseAdapter<Company> {

    Context mContext;

    public CompanyListAdapter(Context context) {
        this.mContext = context;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder;
        Company company = getItem(position);

        if (convertView == null) {
            convertView = View.inflate(mContext, R.layout.item_lv_company, null);
            holder = new Holder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (Holder) convertView.getTag();
        }

        holder.tvName.setText(company.getCompanyName());

        holder.llIndex.setVisibility(View.GONE);
        return convertView;
    }

    class Holder {
        TextView tvName;
        TextView tvIndex;
        LinearLayout llIndex;
        View viewLine;

        public Holder(View view) {
            tvName = (TextView) view.findViewById(R.id.tv_name);
            tvIndex = (TextView) view.findViewById(R.id.tv_index);
            llIndex = (LinearLayout) view.findViewById(R.id.ll_index);
            viewLine = view.findViewById(R.id.view_line);
        }
    }
}
